require File.expand_path('../../config/environment',  __FILE__)

f = File.new(File.expand_path('../../data/shop_category.txt',  __FILE__))
cats = []
f.each_line do |line|
  line = line
  if line =~ /-------------------------/
    cat_one = Category.new(:name => cats.shift, :level => 1) 
    cats.each{|c| cat_one.sub_categories.build({:name => c, :level => 2})}
    cat_one.save!
    cats = []
  else
    cats.concat(line.split(' '))
  end
end
